module string

    interface string_from_integer
        module procedure string_from_integer_sub
        module procedure string_from_integer_fun
    end interface string_from_integer

contains

    subroutine string_from_integer_sub(i, s)
        integer, intent(in) :: i
        character(*), intent(out) :: s

        character(len(s)) :: t
        integer :: j, k

        s = ""

        write(t, "(i)") i

        k = 1
        do j = 1, len_trim(t)
            if(t(j:j) /= ' ') then
                s(k:k) = t(j:j)
                k = k+1
            end if
        end do

        return
    end subroutine string_from_integer_sub

    function string_from_integer_fun(i) result(s)
        integer, intent(in) :: i
        character(100) :: s

        call string_from_integer_sub(i, s)

        return
    end function string_from_integer_fun

end module string
